#ifndef QIKMOVIE_H
#define QIKMOVIE_H

#include "Qik.h"
#include "Movie.h"

class QikMovie: public Movie
{
public:
	QikMovie();
	QikMovie(unsigned int newWidth, unsigned int newHeight);
	~QikMovie();

	void WriteToFile(const char* filename);
	void ReadFromFile(const char* filename);
	void SetCompressionFactor(double factor);
	void SetGopSize(unsigned int newGopSize);
	void SetWindowSize(unsigned int newWindowsize);
	void DisableMotionCompensation();

protected:

private:
	bool motionCompensation;
	double compressionFactor;
	unsigned int gopsize;
	unsigned int windowsize;

	static const char *VERSIONHEADER;
	static const double defaultCompressionFactor;

	static const unsigned int MACROBLOCKW = 16, MACROBLOCKH = 16;
	//static const unsigned int defaultWindowSize = 80;
	static const unsigned int defaultWindowSize = 2*16;

	void WriteHeaderToStream(ByteStream& stream);
	void ReadHeaderFromStream(ByteStream& stream);
	void WriteIFrameToStream(Qik& frameencoder, Image& frame, ByteStream& stream);
	void WritePFrameToStream(Qik& macroencoder, Image& prevframe, Image& frame, ByteStream& stream);
	void ReadIFrameFromStream(Qik& framedecoder, Image& frame, ByteStream& stream);
	void ReadPFrameFromStream(Qik& macrodecoder, Image& prevframe, Image& frame, ByteStream& stream);
};

#endif //QIKMOVIE_H
